package com.foreknow.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import com.foreknow.bean.Admin;
import com.google.gson.Gson;

public class ActionServlet extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		PrintWriter out = resp.getWriter();
//		out.println("ajax.....");
		Admin admin = new Admin();
		admin.setAdminId(1);
		admin.setAdminName("tom");
		admin.setPassword("123");
		
		//使用GSON转换工具将对象转换为Json串
		Gson gson = new Gson();
		String str = gson.toJson(admin);
		out.println(str);
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doGet(req, resp);
	}
}
